package com.fr.data.util.function;

import java.sql.Date;

public class DateFunction extends AbstractDataFunction
{
  private Date result;

  public DateFunction()
  {
    reset();
  }

  public void reset()
  {
    this.result = new Date(System.currentTimeMillis());
  }

  public void addData(Object paramObject)
  {
    if (paramObject == null)
      return;
    if (paramObject instanceof Date)
      this.result = ((Date)paramObject);
    else
      try
      {
        this.result = Date.valueOf(paramObject.toString().substring(0, 10));
      }
      catch (NumberFormatException localNumberFormatException)
      {
        this.result = null;
      }
  }

  public Object getResult()
  {
    return new Long(this.result.getTime());
  }

  public String getFormula()
  {
    return "date";
  }
}